﻿//在线帮助文件
var _MyHelpfile = "/MyWorkflow/help/流程管理/我办理的流程/流程审批.htm";

var sDocType;
function hv_load(){

    sDocType = document.getElementById("__DocumentType").value
	switch(sDocType)
	{
		case "0":	//业务表单
			loadHtml();
			document.getElementById("Span2").style.display = "none";
			break;
		case "1":		//普通文档

			document.getElementById("tab_0").innerHTML = ObjectScript;
			break;
		case "2":		//扩展表单
			loadHtml();
			document.getElementById("Span2").style.display = "none";
			break;
		case "3":
		    document.getElementById("tab_0").innerHTML = ObjectScript;
		    break;
	}
	
	//绑定历史审批附件
	sFkGUID = document.getElementById("__oid").value;
	getDocHtml();
	if(document.getElementById("__mode").value == "3"){
	    document.getElementById("aUpFile").style.display = "none";
	}
}

function loadHtml(){
    myXmlHttp.callByAsync("/MyWorkflow/WF_Document_Get.aspx?DocumentType=" + document.getElementById("__DocumentType").value + "&DocumentGUID=" + document.getElementById("txtDocumentGUID").value + "&rnd=" + Math.random(),"",loadHtmlAsync);
}

function loadHtmlAsync(sText)
{
	var _objFormContext = document.frames("appIframe_HtmlForm").document;
	
	_objFormContext.body.innerHTML = sText;
	
	//HTML表单完善，历史表单，取消添加样式
	//添加样式
	//if(!applyFormFieldStyle(_objFormContext)) return false;
	var spanList = _objFormContext.getElementsByTagName("span");
	var options = null,kvpair;
	for(var i=0,j=spanList.length ; i<j ; i++)
	{
	    if (spanList[i].dm_displaytype && spanList[i].dm_displaytype=="select")
	    {
            options = spanList[i].dm_dropdownoptions.split("|");
            for(var x=0,y=options.length;x<y;x++)
            {
                kvpair = options[x].split(",");
                if (kvpair[0]==spanList[i].value)
	            spanList[i].innerText = kvpair[1];
	            //spanList[i].border = "";
	        }
	    }
	}
	var inputList = _objFormContext.getElementsByTagName("input");
	for (i = 0; i < inputList.length; i++) {
	    if (inputList[i].type == "text") {
	        inputList[i].readOnly = true;
	        if (inputList[i].dm_displaytype == "number") {
	            inputList[i].style.textAlign= "right";
	        }
	    }
	}
	var areaList = _objFormContext.getElementsByTagName("textarea");
	for (i = 0; i < areaList.length; i++) {
	    areaList[i].readOnly = true;
	}
}

function loadDoc(){
    var sDocType = $id("__DocumentType").value;
    var sDocString = sDocType == "3" ? "Excel.Sheet" : "Word.Document";
    var sUrl = document.URL.substring(0,document.URL.lastIndexOf("/")) + "/WF_Document_Get.aspx?DocumentType="+sDocType;
	sUrl += "&DocumentGUID=" + $id("txtDocumentGUID").value; 
	sUrl += "&rnd=" + Math.random();

	oFrame = document.getElementById("oframe");
	oFrame.Open(sUrl, true, sDocString);
	InitOfficeObject(oFrame,sDocString );
	//默认只读保护
	if (sDocType=="1")
		SetDocProtection(oFrame , 3);
	else	
	{
		oFrame.ProtectDoc(1,0,"MYsoft2006WORD");
		//设置批注的显示方式：-1 = xlCommentAndIndicator，0 = xlNoIndicator，1 = xlCommentAndIndicator
		oFrame.ActiveDocument.Application.DisplayCommentIndicator = -1;
	}
	DisplayToolBars(oFrame , false)
}